﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
public partial class DungVM_Search : System.Web.UI.Page
{
    
    VacancyMethord VM = new VacancyMethord();
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack){
        viewalVacancy();
        }
    }
   
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        filvacancybyJob();
    }
    public void viewalVacancy() {
        DataTable tb = VM.ViewAllVacancy();
        grvSearchVacancy.DataSource = tb.DefaultView;
        grvSearchVacancy.DataBind();
        for  (int i=0;i<tb.Rows.Count;i++ )
        {
            grvSearchVacancy.Rows[i].Cells[5].Text = tb.Rows[i]["DateFulfilled"].ToString().Substring(0, tb.Rows[i]["DateFulfilled"].ToString().IndexOf(" "));
        }
    }
    public void filvacancybyJob() {
        
        try
        {
            DataTable tb = VM.VacancySearch(txtJob.Text.ToString());
            grvSearchVacancy.DataSource = tb.DefaultView;
            grvSearchVacancy.DataBind();
            for (int i = 0; i < tb.Rows.Count; i++)
            {
                grvSearchVacancy.Rows[i].Cells[5].Text = tb.Rows[i]["DateFulfilled"].ToString().Substring(0, tb.Rows[i]["DateFulfilled"].ToString().IndexOf(" "));
            }
        }
        catch (Exception ex)
        {

            Console.Write(ex.Message);
        }
    }
}